<script type="text/javascript">
function base_url (){
	return "<?php echo base_url()?>";
}
window.gcConf = typeof window.gcConf == 'undefined' ? {} : window.gcConf;
window.gcConf = $.extend(window.gcConf,{
	unset_image_preview : <?php echo $this->unset_image_preview?'true':'false' ?>,
	unset_image_preview_anchor :<?php echo $this->unset_image_preview_anchor?'true':'false' ?>,
	subject_cls:'<?php echo strtolower(preg_replace('/\s/i', '-', $subject))?>',
	subject:'<?php echo $subject?>',
	state:<?php echo json_encode(ucfirst($this->getState()))?>
});  


</script>

<?php

	$this->set_css($this->default_theme_path.'/flexigrid/css/flexigrid.css');
	$this->set_js_lib($this->default_theme_path.'/flexigrid/js/jquery.form.js');
	$this->set_js_config($this->default_theme_path.'/flexigrid/js/flexigrid-add.js');

	$this->set_js_lib($this->default_javascript_path.'/jquery_plugins/jquery.noty.js');
	$this->set_js_lib($this->default_javascript_path.'/jquery_plugins/config/jquery.noty.config.js');

	$this->set_css($this->default_css_path.'/../../css/error_alert.css');
	$this->set_js_lib($this->default_javascript_path.'/../../js/error_alert.js');
?>
<div style='width: auto;<?php echo !$this->config->dialog_forms?'margin-top: 77px;':''?>' class="flexigrid crud-form add <?php echo strtolower(preg_replace('/\s/i', '-', $subject))?> <?php echo $ci->config->item('grocery_crud_dialog_forms') ? '':'rounded' ?>" data-unique-hash="<?php echo $unique_hash; ?>">
<div class="fly-l"></div>
<div class="fly-r"></div>
	<?php if(!$this->config->dialog_forms){?>
	<div  style="height:120px;" class="tDiv ui-accordion-header ui-helper-reset ui-state-default ui-corner-all ui-accordion-icons" style="display:<?php echo $ci->config->item('grocery_crud_dialog_forms') ? 'none':'block' ?>">
		<div class="ftitle">
			<div class='ftitle-left list-title-pre'>
				<h3><?php echo $this->l('form_add'); ?> <?php echo $subject?></h3>
			</div>
			<div class='clear'></div>
		</div>
		<div title="<?php echo $this->l('minimize_maximize');?>" class="ptogtitle">
			<span></span>
		</div>
	</div>
	<?php } ?>
<div id='main-table-box' class="main-table-box-add">
	<?php echo form_open( $insert_url, 'class="frm-'.strtolower(preg_replace('/\s/i', '-', $subject)).'" method="post" id="crudForm" autocomplete="off" enctype="multipart/form-data"'); ?>
		<div class='form-div'>
			<?php
			$counter = 0;
				foreach($fields as $field)
				{
					$even_odd = $counter % 2 == 0 ? 'odd' : 'even';
					$counter++;
			?>
			<div class='form-field-box <?php echo $even_odd?>' id="<?php echo $field->field_name; ?>_field_box">
				<div class='form-display-as-box' id="<?php echo $field->field_name; ?>_display_as_box">
					<?php echo $input_fields[$field->field_name]->display_as; ?><?php echo ($input_fields[$field->field_name]->required)? "<span class='required'>*</span> " : ""; ?> 
				</div>
				<div class='form-input-box' id="<?php echo $field->field_name; ?>_input_box"> <span class="titik-dua">:</span>
					<?php echo $input_fields[$field->field_name]->input?>
				</div>
				<div class='clear'></div>
			</div>
			<?php }?>
			<!-- Start of hidden inputs -->
				<?php
					foreach($hidden_fields as $hidden_field){
						echo $hidden_field->input;
					}
				?>
			<!-- End of hidden inputs -->
			<?php if ($is_ajax) { ?><input type="hidden" name="is_ajax" value="true" /><?php }?>
		<!-- 	<div class="close-btn">close</div> -->
			<div id='report-error' class='report-div error'>

			</div>
			<div id='report-success' class='report-div success'></div>
		</div>
		<div class="pDiv">
			
<?php 	if(!$this->unset_back_to_list) { ?>
			<div class='form-button-box'>
				<!-- REPLACE WITH BUTTON ICON -->
				<button id="cancel-button" class="btn btn-large">
					<i class="fa fa-times"></i>&nbsp;<?php echo $this->l('form_cancel'); ?>
				</button>
				<!-- <input type='button' value='<?php echo $this->l('form_cancel'); ?>' class="btn btn-large" id="cancel-button" /> -->
			</div>
			<!-- <div class='form-button-box'>
				<input type='button' value='<?php echo $this->l('form_save_and_go_back'); ?>' id="save-and-go-back-button"  class="btn btn-large"/>
			</div> -->
			
<?php 	} ?>
			<div class='form-button-box'>
				<!-- REPLACE WITH BUTTON ICON -->
				<button id="save-and-go-back-button" class="btn btn-large">
					<i class="fa fa-check"></i>&nbsp;<?php echo $this->l('form_save'); ?>
				</button>
				<!-- <input id="save-and-go-back-button" type='submit' value='<?php echo $this->l('form_save'); ?>'  class="btn btn-large" style="padding:5px;"/> -->
			</div>
			<div class='form-button-box'>
				<div class='small-loading' id='FormLoading'><?php echo $this->l('form_insert_loading'); ?></div>
			</div>
			<div class='clear'></div>
		</div>
	<?php echo form_close(); ?>
</div>
</div>
<script>
	var validation_url = '<?php echo $validation_url?>';
	var list_url = '<?php echo $list_url?>';

	var message_alert_add_form = "<?php echo $this->l('alert_add_form')?>";
	var message_insert_error = "<?php echo $this->l('insert_error')?>";

	$('#save-and-go-back-button').focus();
</script>